Skip to content

Fix a hang when stopping code during big screen redraws - #23

Merged
tannewt merged 1 commit into
tannewt:lvgl_displayiofrom
mikeysklar:lvgl-compose-batch
Nov 16, 2026
Merged

tannewt merged 1 commit into
tannewt:lvgl_displayiofrom
mikeysklar:lvgl-compose-batch

Conversation

@mikeysklar

Copy link
Copy Markdown

What

Draw a TileGrid's changed cells in batches of 64.

Why

Redrawing a big TileGrid took seconds and could hang the board on Ctrl-C.

Full TileGrid redraw Before After
400 cells 110 ms 70 ms
1600 cells 4770 ms 266 ms
7200 cells not run 1187 ms
Ctrl-C while homeview runs Before After
Hung, during slider drag 3 of 4 0 of 6
Hung, other phases 0 of 1 0 of 2

Each queued lv_draw_image() walks the whole task list in lv_draw_add_task(), so one layer per grid grows with the square of the cells.

Finishing the layer every 64 cells keeps it linear.

Tested
Board Metro ESP32-P4, Raspberry Pi Touch Display 2
Build 11.0.0-alpha.3 on lvgl_displayio plus this commit
Timing display.refresh() after changing every cell, 1 run each
Ctrl-C stop code.py at 64-76 s, check the REPL answers

AI assistance

Claude Code wrote this change and ran the tests above. I reviewed the diff and tested homeview by hand on the board.

🤖 Generated with Claude Code

The compose pass queued one LVGL draw task per changed cell and drew
them all at the end. LVGL walks its whole task list to add or dispatch
each task, so a full redraw took time with the square of the cell
count. A 1600 cell grid took 4.8 s, and stopping code.py while a big
grid was redrawing held the LVGL lock long enough to hang USB.

Drawing every 64 queued cells makes it linear and caps the queue at 64
tasks instead of one per cell. A tail pointer in lv_draw_add_task()
would fix the root cause upstream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@tannewt tannewt left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannewt
tannewt merged commit 10e56de into tannewt:lvgl_displayio Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants